#include <iostream>
#include <cstdio>
using namespace std;
#define maxn 100005
#define inf 0x7fffffff
int arr[maxn], tmp, len, o1 = -inf, o2 = -inf;
int f[maxn], g[maxn];
int main()
{
    while (scanf("%d", &tmp) != EOF)
    {
        arr[len++] = tmp;
    }
    fill(f, f + len, 1);
    fill(g, g + len, 1);
    for (int i = 0; i < len; ++i)
    {
        for (int j = 0; j < i; ++j)
        {
            // 最长下降子序列
            if (arr[j] >= arr[i])
                f[i] = max(f[i], f[j] + 1), o1 = max(o1, f[i]);
            //最长上升子序列
            else
                g[i] = max(g[i], g[j] + 1), o2 = max(o2, g[i]);
        }
    }
    printf("%d\n%d", o1, o2);
    return 0;
}